package com.example.common.ui;

import android.support.v4.app.Fragment;
import com.example.common.widget.state.NetworkStateView;
import com.example.common.widget.state.OnAnewRequestNetworkListener;

public abstract class NetworkStateFragment extends Fragment implements OnAnewRequestNetworkListener, NetworkStateView {

//    private NetworkStateLayout mStateLayout;
//
//    @Override
//    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//        mStateLayout = (NetworkStateLayout) inflater.inflate(
//                R.layout.fragment_network_state, container, false);
//
//        mStateLayout.addView(inflater.inflate(layoutResId(), mStateLayout, false));
//        mStateLayout.setOnAnewRequestNetworkListener(this);
//        return mStateLayout;
//    }
//
//    @Override
//    public void notNetwork() {
//        if (mStateLayout != null){
//            mStateLayout.showNetworkStateView(NetworkStateLayout.NOT_NETWORK_STATE);
//        }
//    }
//
//    @Override
//    public void loadingNetwork() {
//        if (mStateLayout != null){
//            mStateLayout.showNetworkStateView(NetworkStateLayout.LOADING_NETWORK_STATE);
//        }
//    }
//
//    @Override
//    public void successNetwork() {
//        if (mStateLayout != null){
//            mStateLayout.showContentView();
//        }
//    }
//
//    @Override
//    public void errorNetwork() {
//        if (mStateLayout != null){
//            mStateLayout.showNetworkStateView(NetworkStateLayout.ERROR_NETWORK_STATE);
//        }
//    }
//
//    @Override
//    public void emptyNetwork() {
//        if (mStateLayout != null){
//            mStateLayout.showNetworkStateView(NetworkStateLayout.EMPTY_NETWORK_STATE);
//        }
//    }
//
//    @Override
//    public void onAnewRequestNetwork() {
//        loadingNetwork();
//        new Handler(Looper.myLooper()).postDelayed(this::onAnewRequest, getResources().getInteger(R.integer.load_duration));
//    }
//
//    /**
//     * 重新请求网络
//     */
//    public abstract void onAnewRequest();
//
//    /**
//     * 显示布局
//     */
//    public abstract @LayoutRes
//    int layoutResId();
}
